<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${package}.mapper.${table_name}Mapper">
    <!-- 添加 -->
    <insert id="insert" parameterType="${package}.bean.${table_name}">
        INSERT INTO ${raw_table}(<#list table_columns as column>${column.columnName}<#if column_has_next>,</#if></#list>)
        VALUES (<#list table_columns as column>#${r"{"}${column.dataName}}<#if column_has_next>,</#if></#list>)
    </insert>
    <!-- 修改 -->
    <update id="update" parameterType="${package}.bean.${table_name}">
        UPDATE ${raw_table}
			<set>
			<#list table_columns as column>
				<#if column.isPrimary != "1">
					<if test="${column.dataName} != null">
					${column.columnName} = #${r"{"}${column.dataName}}<#if column_has_next>,</#if>
					</if>
				</#if>
			</#list>
			</set>
			WHERE ${primary_key}=#${r"{"}${j_primary_key}}
    </update>
    <!-- 删除 -->
    <delete id="deleteById" parameterType="java.lang.String">
        DELETE FROM ${raw_table} WHERE ${primary_key}=#${r"{"}${j_primary_key}}
    </delete>
    <!-- 根据主键查询 -->
    <select id="queryById" parameterType="java.lang.String" resultType="${package}.bean.${table_name}">
        SELECT
			<#list table_columns as column>${raw_table?substring(0,1)}.${column.columnName}<#if column_has_next>,</#if></#list>
        FROM ${raw_table} ${raw_table?substring(0,1)} WHERE ${raw_table?substring(0,1)}.${primary_key}=#${r"{"}${j_primary_key}}
    </select>
	<!-- 查询 -->
	<select id="getList" parameterType="${package}.bean.${table_name}" resultType="${package}.bean.${table_name}">
		SELECT
			<#list table_columns as column>${raw_table?substring(0,1)}.${column.columnName}<#if column_has_next>,</#if></#list>
		FROM 
			${raw_table} ${raw_table?substring(0,1)}
	</select>
</mapper>